Fixed broken logic (#591)