added input derivatives calculation