Code for cs295k