finished but with minor bugs