Added code from demo