Commented code and fixed formatting