tested partition subroutine