cleanup
intermediate - implement IDL algorithm from Brewin