finished version, with all modifications