Improve mark algorithm