Rating: refactor code