some refactoriing