Refactoring nested ifs and creating individual gene summaries