reduced complexity and prevented some exceptions