Maybe the "show" function could be called once at the end of the foreach loop.