latest code to make max length db driven