refactored and cleaned up code
fixed merge conflict