move database operations into struct
small polish