very complex. reccommend you do not attempt to modify