The REQUIRE checks should be at the top of the function before any assignments or code. Move the REQUIRE check to the top.