functions done,bug fixed,TODO:print to file