abstracting database from controller