cleaning up and refractoring