fixed end function