Wrapping functions to catch the exceptions