Why conditions are not working?