add different to check for null for functions for nodes and edges
refactor code again :((