add safety return statements to handle errors