Although I am not sure about it, please move the "if" statement inside listener in order not to duplicate code, thanks