refactored with multiple methods