Refactor network service