much better way of computing levels