modify to slightly refactor on IF statement