refactored mobile.js to be more DRY