Lines 64-77 and 83-96 seem to be the same. Create a new inline'd function for this part. (DRY)