started writing counting algorithm for client