added on error listener
minor cosmetics