new code works. needs cleanup.