Updated the collect function and passed through JS Lint