Error. TypeError: Cannot call method 'slice' of null