some optimazations, but no final commit