Adapted changes inpired by David Sulc