moving if to end of file