got rid of an unnecessary loop