fix loop, adapting grey value