fixes bug #22 (thanks for commenting on my previous attempt to fix bug #22)