wrap selected js with an anonymous function