Convert Totp to a function