fix bug in detecting sources