moved loop to main()

to allow for easy changes in later parts of hw (can be run from another
module), should be no functional change