finished part of the code