MINOR CHANGES TO ALL THE FILES, IMPLEMENTED fitTree function