Now adds functions to array prototype and checks validity