improve source locate function