final code used in demo gg