Implemented steps 1 to 3