Extracting more sub functions