Minor refactor; still not working properly