more efficient way to handle search a partition. add unit test for it.