Fixed a minor bug and hopefully sped things up by not using np.where