Resolve the if without end issue