added map and fixed query