logic problem fixed