fixes function and adds end