first phase of logic in server