implemented counting