Refactored and commented all again