final solution for level3 -- ~4000 points