Updated to work correctly.