finished function refactoring