Bug when using inheritance?