implemented insert by query analysis