refactor + fix bug for deploy