refactor more for test and producdtion code