Fixing offsetLeft of null error