Callback functions are not executed immediately