createTree func changed to version 2