Refactor fitting in separate function
Pass fitting function as argument
Add the fitting with tablesize as x variable