refactorized + added  feature