Added explicit prototype for callback function and fixed code accordingly