finished writing the coding. not tested