fixed a bug in couple of cases