refactored try_or_return