Style fix - use when instead of if
Fix paths with spaces not working on linux & osx