Cleaned Code and added comments