Fixing all bugs, and it works nicely now