added timeout function to handle lost connection
added message for counting