Refactored matrix away from stupid switch system