Refactored code to prevent E_STRICT notices