rearranged to simplify