Added checks for callback before attempting to run it