remove duplicating code