updated root directory detection