reindent, added some simple functions