Working version added db backend. still buggy