Rewrite the whole function.