trying to write better array code for bash