use try() to clean up the code a bit