Corrected indentations, added more functionality