simple logic problem