Fixing bugs and trigger event