solved scope problem inside intervals