Improved inserting and updating