made code a bit cleaner by using the code_ref instead of stupid search