fixed some wrong if conditions