changing to tree struct