The bug with 'typeof' condition fixed. Thanks to Alexander Kovalevsky who found it.