improved run algorithm