First working version. No error checking whatsoever.