updated code [time: 0.5]