updated code after Coder review (mainly just indentations)