Vectorized the do2 functions & magdec