ifdef for capability code
Fixed error handler