use numpy for array operations to speed things up