fix viewPath' bug, improve code

define in function to support multi server