Replaced some helper functions with classes