tidied up contains string method to deal with empty strings