fix viewPath' bug, improve code

@zedgu it is not safe