added isEmpty() test to beginning of function calls