rearranged to be more proper