Fixed bug referencing sourcedb before assignment