changed the underlying algorithm to rows