fixed isSingular function