fixed issue #56
fixed issue #54 in a generic way