Made it so the next piece command works correctly
Rearranged the code