initial commit, working code, improvement suggestions welcome