Fixed bug with conditions