better handling of paths and errors