added null pointer checks to add and update patron