add in some code to check for empty cases