add if to prevent crash