merge phuslu's code