move code to remove redundancies

fixes #7