Refactor to export reptition in if's