added Bill Piel's bug fix