Changed all count instances to |length to prevent naming conflicts