general code cleanup - moved functionality from main loop in functions
general code cleanup - moved functionality from main loop in functions

siliconchris1973/fairytale,siliconchris1973/fairytale,siliconchris1973/fairytale,siliconchris1973/fairytale,siliconchris1973/fairytale