Moved db manipulation code to its own package and using reader writer concept