Added try - catch snippet and some other changes