remove duplicate code and use defs