Changed length variable to count words correctly