rebuilt to include map function