Fixed potential error that could cause crash