Updated mattys code with some awesome sauce