rethought the logic