Tidied Code and added remarks