Optimize implemention.