You should check the latest implementation. I already refactored this.