extracting the common functionality and working with modules