finished
code refactored