use peek function to lookahead