Made code more readable and included docs