moved if statement corrected end block