fix logical mistakes