latest code - probably a hot mess