first draft. has bugs.