Cleaned up code to match in with Hints and Tips from Moodle site