Writing new db layer