refactored inline with event driven handling