refactorisation of userHandler code