adding singularity check