first tested version
removed unnecessary code