add some before hooks and install guard