Refactor semantic filename function