some refactoring regarding issuec #4