updated code using rubocop