added functions for taking the dual