standardising program flow and perl conventions a little
minor formatting