Handled error handling at appropriate places