Refactored code and moved into relevant folders