simplify code
fixed for many spaces in path
added explanation
fixed for many spaces in path

by using regexp global switch