updated code v4