fixed potential bug. Function returns reference to local variable. /Thomas Schoenemann