refactor code due to changes on server side