First impl of count kernel