Logic should be correct; need to make it a thread