Finished barak's countConnect implementation for isValidMove