Tally My Gear refactored using postgresql