modified function addRelativeDirectory