Added the final logic