Use basename instead of substr and strrpos