[#1814] some code refactor