If you add a case for !empty basename here you can use it to replace some other code used in other areas