refactored code to new interface