Finally finished this code.