adopt cgsee's implementation #18