fixed final if statement