some refractoring for readability