added while loops & scoped variables for m5