refactoring and improving logstash implementation