second attempt, removed unnecessary code