move ping and data function to Controller