a lot of lines and ifs... i have a bad findbugs feeling...