initial version

works, but there are some display bugs.