Final commit, revised code