add update feature

major refactor to make code cleaner