I know this code just moved, but better as a class