fixing if statement that executes script