worked on user functions and refactoring