Fixed variable initialization error
Fixed exception handling