implemented restriction by sql conditions