tweak and refactor