added three checks
fixed merge conflict