mostly working code
mostly working code