implemented bug fix for TypeError on line 193