add some exception handling to make helper methods more robust