fixed toRad function