Cleanup some code and use function for easier management
Use function for determining if its ppp type