working on db logic for workflow