fixed all logig bugs