preventing a crash and giving an appropriate output to stderr