grr... need to clean up the ulgy in this code...