tightening up gmail api code