commented code, improved indentations