changed a few stuff
merging mudit's code
added gradients
merging