big refactor to enforce data structure