tested gradient - FIXED bug with gradient
hmm not tested..