Reduce conditional within loop