added a necessary check condition