split controller code in function related files