Changed mostly the body of the function compressCore