refactored to use module self extend, and also enhanced rubocop task