Change nested ifs to methods