fixing findDevice. wrong placement of vars