Changed order of the set database command to set databatse to ENV variable first