Split into multiple functions.