doing the elemwise operations outside of scan now, substantially faster