resorted code and added test data and stuff