Added final function, cleaning up code and indentation before submitting.