Added a check for the trailing path separator