refactoring server+api