handles callbacks and check function