Cleaned up the added code to create a smaller method