changed code to inclide '$root'