fixed bug in cosinus calculation