refactored to methods