average karma working; refactored database file