code refactored in order to improve the abstraction