Conditions not working some times?