Refactor old code