Editing a few errors from the beginning of the function