move treeview code to a separate file