Moved db access to a seperate file