additional checks for nil for safety, change functions on nodes into methods