Final revision. All functions work correctly.