First implementation which completes the spec
Fix glaring security flaw