Re-wrote exercise code.