de-duplicate code