modified check logic