width catulation for mobile devices moved to a function