function complate. TODO: handle UI blocked problem