fix cliping bug, but program still will crash at some condition.