Fixed undefined server error, and returned server at end of function