Adding isset condition to prevent PHP Notices