fixed exception handling