major storage refactor into single insert function