error loop, use $die switch flag to stop loop