refactored using methods