fixed logic and rearranged sub collections
fixed db logic