if statement for checking if frame is undefined