Optimized get dist to use numpy array indexing (and removed prints)