syntax fixes based on shellchecker.net feedback
fix typo in variable name