cleaned up logic.