refactored briefly