Use record instead map. Add logging