Add condition to prevent nil from appearing