Update to tested and working code