optimize some function.