added a and b calculations