suggested changes from @dblock