making method to update state