extract packet parsing into helper module

extract packet parsing into helper function and try to make it a little easier to understand