Reworked code to be a bit better, and more dynamic.

Signed-off-by: Hugo_the_Dwarf <edgaredward2010@gmail.com>