server side refactor