Splitting into several functions works rather fine