initial working code