Refactored for providing answer instead of solution