toast's refactor