Moving helper function to inc.js and cleanup
Refactored functions into includes file