[MERGED] modularising code to improve readability

This topic has been merged into Noob alert.