fix callback method to not use undefined objects