combine some redundant code