refactored packages and message handling method