moved sql call out to model