refactored code and added instructions