Splitting function to better locate error