Refactored code and added instructions