Added checking functions for next and previous nodes