Rewritten in a class, with a more general function structure