slight refactor to make the code more readable