Implemented the derivation functionality into the main program