refactored to remove unnecessary code