add empty checking logic