check if list isn't null or empty before attempting to use it