cos inverse error fixed