Split into different functions.