bug fix thanks to Will DelHagen