Added generate path function