updated to cope with scala classes