finished the implementation of self calc