moved database access to models