Added average crossings code