Fixing logic for path creation