bugs fixed for #3