Added safety checks