added all the rest of the code