Add conditional to prevent nil exception