refactoring, inspired by Leo's advise