changed end function use