added if condition to prevent error