Using lambdas to avoid sqlite problems