Getting the insert function working