Now it compiles, the count of ends was wrong