fixed class casting problem. will be refactored and testet shortly