Refactored and commented a little bit