fixed typeof bug, L48

fixed typeof bug on line 48 and replaced typeof != 'undefined' with != null