changed demo, cleaned up code