Use dict instead of iterating through classes