fixed bug where check is made after insert