refactor to make it easy-understand