works but not perfect