working final state tree filling