test and tweak logic