Convert to tables, TODO change data structure