IT IS FINISHED (but not optimized, there's still one thing i'd like to change.