Splitting function into smaller chunks