Modified Attach db logic