code refactoring1: basic structure of the code finished