Changed API to accept a callback
Added some temporary debugging