Fixed equality condition and added debug prints