finally finished, can't find any bugs yet