Fixed my last commit and refactored Hannes code