fix bugs
Exception handling