create single insert function
incorporate latest changes from insertFromSelectQuery branch