Code for webapp and native app