code refactoring2: basic structure of the code finished