cleaned up logic for retrieveOrEnroll