Fix bugs in updating the usedtrial value