Changed to dynamic insert queries