make get and put share more code