fixes issue #563 

Michael OTS review
merged change on typeof from next