I have updated the much cleaner code now.