fixing some logic