corrected the null reference to client