improve error message and create filename