some refactorization