working on tree and arrays