fix bug with undefined database var (1)