redoing most of the code