fixed error callback; removed unused function