Bug fixing on Sd computation