untidy code, some minor bugs, want to sleep