tidied up code with rubocop