implementing guessing function