adding some comments describing flow. also using a declare statement instead of eval, and -z on a string comparison