Almost complete robot code