added simple error handling in ajac()