rearranged and cleaned, added libraries