I really quite hate my implementation.
Oh well, submit it anyway..