refactor a complicated line to a readable method