length --> nrow

This was causing errors!