added hooks
code optimizatin, added hooks