code mostly done