You asked if it was correct, the only way to find out would be to test the code yourself.