refactor code, use decorator