some more refactorings - note mail doesn’t work right now