Add more safety checks