fixed error printing
and some style problems