code loop changed a bit