Refactored and cleaned ex6