Zuo/psestimation

Refactory some code to reduce redundancy.