changed to !ctx from ctx===undefined - since null/false/0 cause ctx loop
to break.  also DRY'd the flag