extracting common logic to module