Change if block to correct ending