Extract getUser into a function