Implemented functional loop, must add error handling + improve all