Dealt with looping departments (see departmentservice findloop function)
Still need to work on error handling on client side