Activity service JS snippet refactoring