Move code to plugin