Fixed typeof undefined check