big update and refactor