fix some bugs in view building