Making generic insert function