Added function to fit models