implemented auth logic