Change storing method to database