some refactoring and it's working!!!