fixing an if-end