got cosine to work, not the most efficient