Added complete exception handling