Fixes undefined variable
Adapts to modified interface