Updated with newest code