updated with newest code