refactor user logic functions and server logic