added next stage of code (still work in progress)