refactor - no intended functionality change
code reduction

with some more idiomatic perl