fix viewPath' bug, improve code