Fixed the cos function