defines main out of the if scope so it can be called by external programs