Update Function

Cleaned up the update function and ran some test cases