rewrote ping function, removed switch