Reworked code to be Wordpress code style compliant