Refactored createListener