event waiting instead of polling. closes #3