attempt at refractoring