fixed calc bugs