Refactored to remove unnecessary code.