code with SQL check