foudn the logic problem too tired to fix now.