improving the use of callbacks