almost finish, fixing some small bugs