Cleaned up insert and delete functions to use aggregation