refactored previous hw