long overdue refactor