fix non-exist $history
changed from self-map function to JQuery map function