fixed mistake so that both sine halves are treated properly