use if statement instead of next