implemented stage 1 completely