fix fname cannot be displaied and better error reporting