Fixes #21 Changed to use ndim