implementation for sucessor and predecessor