Legacy function
Appears to work right!
Debug