Created by: wolfy1339
This removes duplicated code in the source, and allows for easier changing and customization