duplicated code and extra boolean