Update Smartshelf_main

I know that loop is very ugly. But it's the only solution I came by.