Preproccess the database