first attempt at refractoring