modified to use guard clause from rubocop