fixed bug in firefox, added nullcheck