Improved ABC with failure checking and added '\0'