add hook instead of code

Should use WP hooks ofcourse