added cosine function