add -f option with better error reporting