fix optional parameters and callbacks

solution to the problem occurred when optional parameters are not passed and implementation of callbacks