Refactor history into separate file