Collection delete problem solved. Saving before inserting javascript