Added some safe checks