Added end nodes
Contributed by : Maarten Zeinstra