implementation of gradients ready for testing