fixed lazy problem and better internal error handling