Simplify procedure, add test data, document logic