Fixed logic in code, split function in half, getting the code finished