more comments in code, added exit 1 on failure