checking logic for insert