Added helper function to group loans into groups based on due date