basePath code refactor