added create node function and cleaned up code