merge repeating code