adjusted rebased version to changed code