Functional version working on jQuery Mobile