completed setmap function