Fixed the program. Now integrates correctly.

Fixed the issue that was had with the functions not behaving correctly.