final code for the grand challenge