move strange code to helpers