Basic loop working, ready to be merged