fixed crash when creating elements