code de-duplication