error handling bug fixed