I have stayed with your code because I think that is the way you will learn and have some fun.

I could post a way (or a few ways) to do the same thing and maybe more efficient or less code or whatever, I dont know that it will help you learn to code or not.
if you want to see another way to do an away "system" use the search feature on the forum and expand it to a 5 year search. there will be more examples there than you can read in a day im sure.
other than that, make what you have Work, then make what you have work more efficient, and when you cant figure something out post like you did and you most likely will get several people posting solutions.