Finished but could refactor out 2/3rds of the lines...