fixed the final block code