refactor resizing, and implement insert