Update: `cos_in` isn't used afterward so not only the multiplication is useless, but the definition of `cos_in` can be moved inside the `if`.