Cleaned up duplicate code

As done by davidgfnet
https://github.com/davidgfnet/whatsapp-purple/commit/6205fcffd988f0986410fd74f77b814f2ae3c368