working on loop and v-sync