refactor query horizontal and vertical in home page