use a more dynamic approach to compute the level (and don't use the potentially very expensive recursive SQL query)