Minor changes to avoid innecessary loops