Finished the coding part. Still need to write a test case.