Added final touches to the code