updating to work without loops