Using rauth and a bit of refactoring