moved code from config to model