combine some identical code