replaced class handling with simpler code