a bit of refractoring