update
updated function for working with array