more robost error handling