more work on the logic