remove some duplication from javascript invokation click code