Why my condition is not working?