use ActiveSupport::Concerns and refactor code