Updated and fixed the code.