Bug fix for double counting