Username check and re-ordering

Now ensure that Username is provided and changed the order of code to
put "main" at the end.